package com.thinkgem.jeesite.modules.tgb.SpringActivemq.mq.consumer.topic;

import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.sys.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * 
 * @author liang
 * @description  Topic消息监听器，监听新增的机构，新增人员
 * 
 */
@Component("topicPeopleRoleReceiver")
public class TopicPeopleRoleReceiver implements MessageListener{

    @Autowired
    private SystemService systemService;

	@Override
	public void onMessage(Message message) {
        try {
            String port = new Global().getConfig("clientId");//获取某一个key的value: clientId=jims-oa
            if (StringUtils.isNotBlank(message.getStringProperty("type")) && message.getStringProperty("type").equals(port)) {
            } else {
                System.out.println("TopicReceiver4接收到消息:" + ((TextMessage) message).getText());
                String type = message.getStringProperty("type");//update,add,delete
//                systemService.saveRolePeop(type, ((TextMessage) message).getText());
            }
        } catch (JMSException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
	}
	
}
